<template>
  <div class="order">
    <div class="content">
      <!-- 面包屑 -->
      <el-breadcrumb separator="/">
        <el-breadcrumb-item :to="{ path: '/' }">首页</el-breadcrumb-item>
        <el-breadcrumb-item>订单管理</el-breadcrumb-item>
        <el-breadcrumb-item>订单列表</el-breadcrumb-item>
      </el-breadcrumb>
      <!-- 表格 -->
      <div class="table">
        <el-table
          ref="singleTable"
          :data="tableData"
          highlight-current-row
          style="width: 100%"
          border
          stripe
        >
          <el-table-column type="index" width="50"></el-table-column>
          <el-table-column property="order_number" label="订单编号" width="295"></el-table-column>
          <el-table-column property="order_price" label="订单价格" width="100"></el-table-column>
          <el-table-column property="pay_status" label="是否付款" width="120">
            <template slot-scope="scope">
              <div v-if="scope.row.pay_status==0">
                <el-button type="danger" size="small">未付款</el-button>
              </div>
            </template>
          </el-table-column>
          <el-table-column property="is_send" label="是否发货"></el-table-column>
          <el-table-column property="update_time" label="下单时间"></el-table-column>
          <el-table-column label="操作">
            <template slot-scope="scope">
              <el-button
                type="primary"
                icon="el-icon-edit"
                size="mini"
                @click="handleEdit(scope.$index, scope.row)"
              ></el-button>
            </template>
          </el-table-column>
        </el-table>
      </div>

      <!-- 分页 -->
      <div class="block">
        <el-pagination
          @size-change="handleSizeChange"
          @current-change="handleCurrentChange"
          :current-page="currentPage4"
          :page-sizes="[10, 20, 30, 40]"
          :page-size="100"
          layout="total, sizes, prev, pager, next, jumper"
          :total="total"
        ></el-pagination>
      </div>
    </div>
  </div>
</template>


<script>
import http from "@/api/port";
export default {
  data() {
    return {
      tableData: [],
      currentRow: null,
      total: 0,
      currentPage4: 0
    };
  },
  created() {
    this.orders();
  },
  methods: {
    setCurrent(row) {
      this.$refs.singleTable.setCurrentRow(row);
    },
    handleCurrentChange(val) {
      this.currentRow = val;
    },
    handleSizeChange(val) {
      console.log(`每页 ${val} 条`);
    },
    handleCurrentChange(val) {
      console.log(`当前页: ${val}`);
      this.currentPage4 = val;
    },
    orders() {
      http("orders", {}, "get", {
        pagenum: 1,
        pagesize: 10
      }).then(res => {
        console.log("用户", res);
        (this.total = res.data.total), (this.tableData = res.data.goods);
      });
    },
    handleEdit() {}
  }
};
</script>


<style scoped lang="scss">
</style>
